package com.kzj.laimeimei.global;

import android.app.Application;
import android.content.Context;
import android.support.multidex.MultiDex;
import android.text.TextUtils;
import android.view.Display;
import android.view.WindowManager;

/**
 * Created by xyg on 2015/9/8.
 */
public class App  extends Application {
    public int screenWidth;//屏幕宽度
    public int screenHeight;//屏幕高度
    private static App instance;
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }

    @Override
    public void onCreate() {
        super.onCreate();

        //LeakCanary.install(this);

        //设置崩溃处理
       // CrashHandler crashHandler = CrashHandler.getInstance();
      //  crashHandler.init(getApplicationContext());
        instance = this;
        WindowManager windowManager = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
        Display display = windowManager.getDefaultDisplay();
        screenWidth =windowManager.getDefaultDisplay().getWidth();
        screenHeight = windowManager.getDefaultDisplay().getHeight();

    }

    public static App getInstance() {
        return instance;
    }
    /**
     * 描述：Toast提示文本.
     * @param text  文本
     */
    public static void showToast(String text) {
        if(!TextUtils.isEmpty(text)){
                android.widget.Toast.makeText(App.getInstance(), text, android.widget.Toast.LENGTH_SHORT).show();
        }

    }

    /**
     * 描述：Toast提示文本.
     * @param resId  文本的资源ID
     */
    public static void showToast(int resId) {
        android.widget.Toast.makeText(App.getInstance(),""+App.getInstance().getResources().getText(resId), android.widget.Toast.LENGTH_SHORT).show();
    }
}
